package base;

public class ArrayDemo {
    public static void main(String[] args) {

        int[] arrayName = new int[2];
        System.out.println(arrayName[1]);
       // System.out.println(arrayName[2]);  //java.lang.ArrayIndexOutOfBoundsException  索引越界异常


        int[] arrayName1 = {1,2};
        //arrayName1 = null;
        //System.out.println(arrayName1[0]);  java.lang.NullPointerException 空指针异常


        //遍历取最值
        int max = arrayName1[0];
        for (int i = 0; i < arrayName1.length; i++) {
            if (arrayName1[i] > max) {
                max = arrayName1[i];
            }
        }
        System.out.println(max);

    }
}
